package com.zjht.gmcc.servlet.sys;

import java.io.PrintWriter;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.zjht.gmcc.bean.BaseServlet;
import com.zjht.gmcc.bean.util.MyJDBC;


public class OpersCheck extends BaseServlet {

	private static final long serialVersionUID = 1L;


	public boolean process(HttpServletRequest request, HttpServletResponse response,HttpSession session, PrintWriter out, MyJDBC myJDBC,  String menu)throws Exception {
		response.setContentType("text/xml;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		StringBuilder sb = new StringBuilder("<state>");

		PreparedStatement ps = null;
		ResultSet rs = null;
		String s_opercode = request.getParameter("opercode").trim();
		String s_sql = "SELECT opercode FROM opers where opercode=?";

		ps = myJDBC.prepareStatement(s_sql);
		ps.setString(1, s_opercode.toUpperCase());
		rs = ps.executeQuery();
		if (rs.next())
			sb.append("<value>1</value>");
		else
			sb.append("<value>0</value>");
		rs.close();
		rs = null;
		ps.close();
		ps = null;
		sb.append("</state>");
		out.write(sb.toString());

		return true;
	}
}
